package com.itzol.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itzol.config.Result;
import com.itzol.entity.Consume;
import com.itzol.mapper.ConsumeMapper;
import com.itzol.service.ConsumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Service
public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> implements ConsumeService {
    @Autowired
    private ConsumeService consumeService;
    //消费接口实现
    @Override
    public Result consume(Consume consume) {
//        Calendar calendar = Calendar.getInstance();
//        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
//        consume.setCreate_date(formatter.format(calendar.getTime()));
        Boolean r = consumeService.save(consume);
        if(r){
            return Result.succ("消费成功");
        }
        return Result.erreo("消费异常，请重试");
    }
}
